<?php
include_once('./db.conf');
session_start();
// Connects to your Database 
$connection=mysqli_connect(DBHOST, DBUSER, DBPASS,DBDBNAME); 
if(isset($_COOKIE['CompanyCookie'])){
$query = "call getSurveyForCompany($_SESSION[comID])";
if($check=mysqli_query($connection,$query)){
	//get all surveys belong to this company
	$i=0;
	while($row= mysqli_fetch_assoc($check)){
		$surveyID[$i]=$row['surveyId'];//get all surveyId's belong to this company
		$questionName[$i]=$row['questionName'];
		$question[$i]=$row['question'];
		$i+=1;
	}
	?>
<h4>Surveys For Your Company<h4>
<table border="5">
<?php
//showing surveys
for($count=0;$count<=$i;$count++){
?>
<tr>
  <td><?php echo $surveyID[$count]?></td>
  <td><?php echo $questionName[$count]?></td>
  <td><?php echo $question[$count]?></td>
</tr>
<?php
}
?>
</table>
<form action="showChart.php" method="post">
Select A Survey ID and Click "Show Chart"
<select name="survey">
<?php
for($count=0;$count<$i;$count++){
?>
<option value="<?php echo $surveyID[$count]?>"><?php echo $surveyID[$count] ?></option>
<?php
}
?>
</select>
<input type="submit" name="show" value="Show Chart>>>">
<?php
}
mysqli_close($connection);
}
else
	die('Time Expired Please Login...');
?>